//
//  HZL_travelNotesPageUserTableViewCell.m
//  B_Project
//
//  Created by 胡佳俊 on 15/11/28.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_travelNotesPageUserTableViewCell.h"

@interface HZL_travelNotesPageUserTableViewCell ()

@property (nonatomic, retain)UIImageView *photo;
@property (nonatomic, retain)UILabel *nameLabel;
@property (nonatomic, retain)UILabel *titleLabel;
@property (nonatomic, retain)UILabel *dateLabel;
@property (nonatomic, retain)UILabel *dieKM;
@property (nonatomic, retain)UILabel *dayCountLabel;
@property (nonatomic, retain)UILabel *KMlabel;
@property (nonatomic, retain)UILabel *lineLabelUp;
@property (nonatomic, retain)UILabel *lineLabelDown;
@property (nonatomic, retain)UILabel *lineLabelDown2;
@property (nonatomic, retain)UILabel *lineLable;
@property (nonatomic, retain)UILabel *dieLikeLabel;
@property (nonatomic, retain)UILabel *likeLabel;

@end
@implementation HZL_travelNotesPageUserTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView
{
    
    self.lineLabelUp = [[UILabel alloc]init];
    self.lineLabelUp.backgroundColor = [UIColor colorWithRed:0.76 green:0.78 blue:0.8 alpha:1];
    [self.contentView addSubview:self.lineLabelUp];
    
    self.photo = [[UIImageView alloc]init];
    //    self.photo.backgroundColor = [UIColor colorWithRed:0.73 green:0.73 blue:0.58 alpha:1];
    [self.contentView addSubview:self.photo];
    
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.nameLabel];
    
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.titleLabel];
    
    
    self.dateLabel = [[UILabel alloc]init];
    self.dateLabel.font = [UIFont systemFontOfSize:10];
    self.dateLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.dateLabel];
   
    
    self.dieKM = [[UILabel alloc]init];
    self.dieKM.font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
    self.dieKM.text = @"里程";
    self.dieKM.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.dieKM];
   
    
    self.dayCountLabel = [[UILabel alloc]init];
    self.dayCountLabel.font = [UIFont systemFontOfSize:11];
    self.dayCountLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.dayCountLabel];
  
    
    self.KMlabel = [[UILabel alloc]init];
    self.KMlabel.font = [UIFont systemFontOfSize:11];
    self.KMlabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.KMlabel];
    
    
    
    self.dieLikeLabel = [[UILabel alloc]init];
    self.dieLikeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
    self.dieLikeLabel.textAlignment = NSTextAlignmentCenter;
    self.dieLikeLabel.text = @"喜欢";
    [self.contentView addSubview:self.dieLikeLabel];

    
    self.likeLabel = [[UILabel alloc]init];
    self.likeLabel.font = [UIFont systemFontOfSize:11];
    [self.contentView addSubview:self.likeLabel];
    self.likeLabel.textAlignment = NSTextAlignmentCenter;
    
    
    self.lineLable = [[UILabel alloc]init];
    self.lineLable.backgroundColor = [UIColor colorWithRed:0.76 green:0.78 blue:0.8 alpha:1];
    [self.contentView addSubview:self.lineLable];

    
    self.lineLabelDown = [[UILabel alloc]init];
    self.lineLabelDown.backgroundColor = [UIColor colorWithRed:0.76 green:0.78 blue:0.8 alpha:1];
    [self.contentView addSubview:self.lineLabelDown];

    
    self.lineLabelDown2 = [[UILabel alloc]init];
    self.lineLabelDown2.backgroundColor = [UIColor colorWithRed:0.76 green:0.78 blue:0.8 alpha:1];
    [self.contentView addSubview:self.lineLabelDown2];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    if ([[NSUserDefaults standardUserDefaults]boolForKey:@"isNight"]) {
        self.contentView.backgroundColor = [UIColor colorWithRed:0.28 green:0.28 blue:0.28 alpha:1];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.nameLabel.textColor = [UIColor whiteColor];;
        self.dateLabel.textColor = [UIColor whiteColor];
        self.dayCountLabel.textColor = [UIColor whiteColor];
        self.dieKM.textColor = [UIColor whiteColor];
        self.KMlabel.textColor = [UIColor whiteColor];
        self.dieLikeLabel.textColor = [UIColor whiteColor];;
        self.likeLabel.textColor = [UIColor whiteColor];
        
    }else
    {
        self.contentView.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
    }
    self.lineLabelUp.frame = CGRectMake(10, 60, WIDTH - 20, 1);
    
    self.photo.frame = CGRectMake(WIDTH - 20 / 2 + (self.contentView.frame.size.width - 20)/8,self.lineLabelUp.frame.origin.y - (self.contentView.frame.size.width - 20)/4 , (self.contentView.frame.size.width - 20)/4, (self.contentView.frame.size.width - 20) / 4);
    self.photo.center = self.lineLabelUp.center;
    self.photo.layer.masksToBounds = YES;
    self.photo.layer.cornerRadius = self.photo.frame.size.width / 2;
    
    self.nameLabel.frame = CGRectMake(self.photo.frame.origin.x, self.photo.frame.origin.y + self.photo.frame.size.height + 10, self.contentView.frame.size.width - 10 - self.photo.frame.origin.x, 10);
    self.nameLabel.center = CGPointMake(self.photo.frame.origin.x + self.photo.frame.size.width/2, self.photo.frame.origin.y + self.photo.frame.size.width + 10);
    
    
    self.titleLabel.frame = CGRectMake(30, self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height + 10, WIDTH - 60, 30);
    
    
    self.lineLabelDown.frame = CGRectMake(30, self.titleLabel.frame.origin.y + self.nameLabel.frame.size.height + 30, WIDTH - 60, 1);
    
    
    
    
    self.lineLable.frame = CGRectMake(self.lineLabelDown.frame.origin.x + self.lineLabelDown.frame.size.width / 3, self.lineLabelDown.frame.origin.y + 10, 1, 40);
    
    
    
    self.lineLabelDown2.frame = CGRectMake(self.lineLabelDown.frame.origin.x + self.lineLabelDown.frame.size.width / 3 * 2, self.lineLable.frame.origin.y, 1, 40);
    
    
    if (self.modelNotes.mileage == nil ) {
        self.dateLabel.frame = CGRectMake(self.lineLabelDown.frame.origin.x  + self.lineLabelDown.frame.size.width / 3 + 15, self.lineLabelDown.frame.origin.y + 10, self.lineLabelDown.frame.size.width/3 , 15);
        self.dateLabel.center = CGPointMake(self.photo.center.x, self.lineLabelDown.frame.origin.y + 13);
        self.dayCountLabel.frame = CGRectMake(self.dateLabel.frame.origin.x, self.dateLabel.frame.origin.y + self.dateLabel.frame.size.height + 10, self.dateLabel.frame.size.width, 10);
    }
    
    else
    {
        self.dateLabel.frame = CGRectMake(self.lineLabelDown.frame.origin.x, self.lineLabelDown.frame.origin.y + 10, self.lineLabelDown.frame.size.width/3 , 15);
        
        self.dieKM.frame = CGRectMake(self.lineLabelDown.frame.origin.x  + self.lineLabelDown.frame.size.width / 3 + 25, self.dateLabel.frame.origin.y, 60, self.dateLabel.frame.size.height);
        
        self.dieKM.center = CGPointMake(self.contentView.center.x, self.dateLabel.frame.origin.y + 8);
        self.dayCountLabel.frame = CGRectMake(self.dateLabel.frame.origin.x, self.dateLabel.frame.origin.y + self.dateLabel.frame.size.height + 10, self.dateLabel.frame.size.width, 10);
    }
    
    self.KMlabel.frame = CGRectMake(self.dieKM.frame.origin.x , self.dieKM.frame.origin.y + self.dieKM.frame.size.height + 8, 60, 10);
    
    self.dieLikeLabel.frame = CGRectMake(self.dieKM.frame.origin.x + self.dieKM.frame.size.width / 3  + 80, self.dieKM.frame.origin.y, 60, self.dieKM.frame.size.height);
    self.dieLikeLabel.center = CGPointMake(self.dieKM.center.x + self.lineLabelDown.frame.size.width / 3, self.dateLabel.frame.origin.y + 8);
    
    self.likeLabel.frame = CGRectMake(self.dieLikeLabel.frame.origin.x, self.KMlabel.frame.origin.y, 60, 10);
    
    
}

- (void)setModelNotes:(HZL_RecommendModel *)modelNotes
{
    if (_modelNotes != modelNotes) {
        _modelNotes = modelNotes;
    }
    
    self.titleLabel.text = modelNotes.name;
    self.dateLabel.text = modelNotes.first_day;
    self.dayCountLabel.text = [NSString stringWithFormat:@"%@%@", modelNotes.day_count, @"天"];
    self.KMlabel.text = [NSString stringWithFormat:@"%ld%@", modelNotes.mileage.integerValue, @"KM"];
    self.likeLabel.text = [NSString stringWithFormat:@"%@", modelNotes.recommendations];
    
}

- (void)setModelUser:(HZL_RecommendModel *)modelUser
{
    if (_modelUser != modelUser) {
        _modelUser = modelUser;
    }
    
    [self.photo sd_setImageWithURL:[NSURL URLWithString:modelUser.avatar_l] placeholderImage:nil];
    self.nameLabel.text = [NSString stringWithFormat:@"%@%@", @"by " ,modelUser.name];
    
    
}




//
////攻略
//- (void)setModelAllData:(CXY_guideModel *)modelAllData
//{
//    if (_modelAllData != modelAllData) {
//        [_modelAllData release];
//        _modelAllData = [modelAllData retain];
//    }
//
//    self.titleLabel.text = modelAllData.title;
//
//    self.dateLabel.text = modelAllData.startdate;
//    self.dayCountLabel.text = [NSString stringWithFormat:@"%@%@", modelAllData.days, @"天"];
//
//     [self.KMlabel removeFromSuperview];
//    [self.dieKM removeFromSuperview];
//    [self.likeLabel removeFromSuperview];
//    [self.dieLikeLabel removeFromSuperview];
//
//}
//
//
//
//- (void)setModelOwner:(CXY_guideModel *)modelOwner
//{
//    if (_modelOwner != modelOwner) {
//        [_modelOwner release];
//        _modelOwner = [_modelOwner retain];
//    }
//    NSString *url = [NSString stringWithFormat:@"%@%@%@", modelOwner.picdomain, @"upload/", modelOwner.coverpic];
//    [self.photo sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil];
//
//     self.nameLabel.text = [NSString stringWithFormat:@"%@%@", @"by " ,modelOwner.nickname];
//
//}
//
//- (void)setModelRecords:(CXY_guideModel *)modelRecords
//{
//    if (_modelRecords != modelRecords) {
//        [_modelRecords release];
//        _modelRecords = [modelRecords retain];
//    }
//    
//  
//}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
